package com.shey.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;

import com.shey.fragment.ImageDetailFragment;

import java.util.ArrayList;

public class ImagePagerAdapter extends FragmentStatePagerAdapter {

        public ArrayList<String> photoList;

        public ImagePagerAdapter(FragmentManager fm, ArrayList<String> photoList) {
            super(fm);
            this.photoList = photoList;
        }

        @Override
        public int getCount() {
            return photoList == null ? 0 : photoList.size();
        }

        @Override
        public Fragment getItem(int position) {
            String url = photoList.get(position);
            return ImageDetailFragment.newInstance(url);
        }
    }